package com.jqq.map_;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 姬倩倩
 * @version 1.0
 */
@SuppressWarnings({"all"})
public class MapMethod {
    public static void main(String[] args) {
        //演示Map接口常用方法
        Map map = new HashMap();
        map.put("邓超", new Book("水浒传", 100));
        map.put("邓超","孙俪");//替换book
        map.put("王宝强","马蓉");
        map.put("宋喆","马蓉");
        map.put(null,"刘亦菲");
        map.put("鹿晗","关晓彤");
        System.out.println(map);

        //remove
        map.remove(null);

        //get
        Object value = map.get("鹿晗");
        System.out.println("val=" + value);

        //size
        System.out.println(map.size());

        //isEmpty()
        System.out.println(map.isEmpty());

        //containsKey
        System.out.println(map.containsKey("邓超"));

        //clear
        map.clear();
        System.out.println(map);
    }
}
class Book{
    private String name;
    private int num;

    public Book(String name, int num) {
        this.name = name;
        this.num = num;
    }
}